package arraybase;

/**
 * ClassName: 求数值数值的最大值及所有最大值的下标
 * Package: arraybase
 * Description:
 *
 * @Author fjorid
 * @Create 2025/1/5 19:30
 * @Version 1.0
 */
 class Test13AllMaxIndex2 {
    public static void main(String[] args) {
        int[] arr = {4,5,6,1,9,9,3,9,8,9,9};
        //找最大值
        int max = arr[0];
        String index = "0";
        for(int i=1; i<arr.length; i++){
            if(arr[i] > max){
                max = arr[i];
                index = i + "";//找到最大值后把其下标转换成字符串格式并赋给index。
            }else if(arr[i] == max){
                index += "," + i;
            }
        }

        System.out.println("最大值是" + max);
        System.out.println("最大值的下标是[" + index+"]");
    }
}